"""
工具函数返回多个值给下游使用
"""
from typing import Tuple, List
from langchain_core.tools import tool
import numpy as np

@tool(response_format="content_and_artifact")
def generate_ids_ints(min: int, max: int, size: int) -> Tuple[str, List[int]]:
    """生成指定范围内的随机整数列表"""
    array  = np.random.randint(min, max, size).tolist()
    content = f"Successfully generated array of {size} random ints in [{min}, {max}]."
    return content, array

# 没有打印array, 只返回了工具输出的内容部分
# print(generate_ids_ints.invoke({"min": 1, "max": 10, "size": 5}))
# 为了同时获取内容和工件，我们需要使用 ToolCall 调用我们的模型
result = generate_ids_ints.invoke({
    "name": "generate_random_ints",
    "args": {"min": 0, "max": 9, "size": 10},
    "id": "123",  # required
    "type": "tool_call",  # required
})
print(result)

